-
Notifications
You must be signed in to change notification settings - Fork 33
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Incremental version of the solver #1000
base: next
Are you sure you want to change the base?
Conversation
c27098e
to
432d646
Compare
src/lib/reasoners/satml_frontend.ml
Outdated
@@ -1303,7 +1303,7 @@ module Make (Th : Theory.S) : Sat_solver_sig.S = struct | |||
|
|||
let assume env gf _dep = | |||
(* dep currently not used. No unsat-cores in satML yet *) | |||
assert (SAT.decision_level env.satml == 0); | |||
(* assert (SAT.decision_level env.satml == 0); *) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I commented these assertions because one test failed and I forgot to put them back; the test ./alt-ergo -o smtlib2 --prelude tests/cram.t/prelude.ae tests/cram.t/postlude.smt2
still fails because of it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah because there are push
'd level now. We should probably be able to expose the "push level" and check that instead (i.e. assertion that the decision level is equal to the length of the increm_guard). Probably as a SAT.can_assume env.satml
check or some such.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would it be correct not to assert at the decision level 0
, but at decision_level env
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
expose the "push level"
Both my solution and yours may be incorrect actually.
(assert f) ; decision level = 0, push level = 0
(push 42) ; decision level = 0, push level = 42
(check-sat)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe a counter for every query?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah I realized that after (because for the first check-sat
it will be 0
as it used to be). The correct test I believe is decision_level <= push_level
(to also capture both (check-sat)(push)(check-sat)
and (push)(check-sat)(pop)(check-sat)
).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here's another solution: at the end of a query, keep track of the current decision level and set it as the latest known decision level on the satml_frontend
side. I find it hard to justify keeping the invariant decision_level <= push_level
for a consistency check (in other words, if we ever raise this assertion during a pr, I'm not sure how relevant it would be for debugging).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I find it hard to justify keeping the invariant decision_level <= push_level for a consistency check (in other words, if we ever raise this assertion during a pr, I'm not sure how relevant it would be for debugging).
This is not just a consistency check; I am not sure the solver will do the right thing in this case. In particular, I am not sure the assumed assertions cannot be forgotten upon later backtracking — in fact, I am pretty sure they will be forgotten (partially) for the default CDCL-Tableaux solver given my current understanding of lazy_cnf
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(Note that for decisions level between 0
and push_level
forgetting assumptions upon backtracking is OK because that is exactly the semantics we want for push
and pop
)
src/lib/reasoners/satml_frontend.ml
Outdated
assert (SAT.decision_level env.satml == 0); | ||
try ignore (assume_aux ~dec_lvl:0 env [add_guard env gf]) | ||
|
||
try ignore (assume_aux ~dec_lvl:(SAT.decision_level env.satml) env [add_guard env gf]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should benchmark this PR to be sure this modification is ok :)
if Options.get_tableaux_cdcl () then | ||
Errors.run_error | ||
(Errors.Unsupported_feature | ||
"Incremental commands are not implemented in \ | ||
Tableaux(CDCL) solver ! \ | ||
Please use the Tableaux or CDLC SAT solvers instead" | ||
); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I thought this was still not working — just commenting here to make sure we don't merge until either this works with Tableaux(CDCL) (probably not worth it, waiting on @Halbaroth investigation whether we should remove Tableaux(CDCL)) or to keep the assert back in.
Looks like there are conflict, rebase would be appreciated :) |
21639c6
to
8b80218
Compare
I'm not sure why, but the tests do not pass on the CI, but |
Weird. I can't reproduce either. But on the CI it seems surprisingly reproducible — all runners on all OSes fail. Maybe a cache problem, somehow? |
I'm going to push some commits to this branch to test what's wrong with the tests on the CI, please don't take them into account |
Here's the CI's result :
There is no line 1990 in |
3ba929d
to
d4cd365
Compare
2efa175
to
2fd8303
Compare
Okay I finished working on the pop-reinitialization version. What it does now is to rework all the analysis (removing the smt commands we don't want to be executed twice) when a pop occurs. I will add some documentation to explain what's going on, but at least tests are OK on my machine. |
Ah so this uses a |
You marked this as ready for review but also noted this; should I wait for that documentation to be written before doing a review or do you want a pass now? |
I thought I was ready modulo documentation, but as I wrote documentation I noticed a few issues remaining (cf CI). Ready for review in a minute |
Ready! For real this time |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I did a first pass; I will do a second more thorough one later this week but there is still actionable feedback. I wish we had to extract less stuff from D_cnf
but oh well.
We need to run benchmarks on both internal datasets (AE format and SMT format) in both modes, will queue them tonight
src/lib/reasoners/satml.ml
Outdated
@@ -999,9 +1004,11 @@ module Make (Th : Theory.S) : SAT_ML with type th = Th.t = struct | |||
let print_aux fmt hc = | |||
Format.fprintf fmt "%a@," Atom.pr_clause hc | |||
|
|||
let is_unsat env : unit = env.is_unsat <- true |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please call this function set_unsat
or set_is_unsat
:)
(* This was first added by PR 1000, but it triggers a bug in | ||
tests/cc/testfile-ac_cc002.ae with option | ||
--no-tableaux-cdcl-in-instantiation *) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If this code is removed then I believe the unit_tenv_queue
field should also be removed (in fact I think it should be removed in any case, it was a quick-and-dirty hack to test an hypothesis if I recall — same goes for this code).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it was important to restore the old unit_tenv from before a push (cf Satml.pop)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe this should only be the case with the code below uncommented — without this code, Alt-Ergo should only ever add to unit_tenv
facts that are true at level 0
(otherwise it is probably a soundness bug) which shouldn't be impacted by push/pop.
(If I recall correctly, I added this code and the unit_tenv
stack because unit_tenv
with the specification of only adding things known at level 0
is less useful with incremental solving and we were trying to solve the performance issues)
9570638
to
cf3b8a2
Compare
9955e61
to
a0f518e
Compare
I can't figure out why there is a test not working on the CI that works on my side. I guess this is because the CI is slow, but I'm not sure where the error is triggered... |
The test is |
The target of this PR: the first part before getting rid of the Commands module. As the legacy frontend still relies on it, this PR only cuts all the dependencies of the dolmen loop (solving_loop.ml)